﻿@{
    ViewBag.Title = CloudStorageLight.Core.Web.ViewMessages.MsgLogin;
    Layout = "~/Views/Shared/_Layout.cshtml";
    var withDomainMode = string.IsNullOrEmpty(CloudStorageLight.Core.BlobService.GetCurrentDomain()) && CloudStorageLight.Core.SystemSettings.Instance.MultiDomain;
    var query = new RouteValueDictionary();
    foreach (string key in Request.QueryString.Keys)
    {
        if (key == null)
        {
            continue;
        }
        query[key] = Request.QueryString[key].ToString();
    }
 }

<div id="maindiv">
    <h2>@ViewBag.Title.</h2>
    <div class="row">
        <div class="col-md-10">
            <section id="loginForm">
                <form class="form-horizontal" method="POST" action="Login?returnUrl=@(ViewBag.ReturnUrl)">
                    @Html.AntiForgeryToken()
                    @Html.Hidden("ReturnUrl", (object)ViewBag.ReturnUrl)
                    @Html.Hidden("ClientToken")
                    <hr />
                    @Html.ValidationSummary(true, "", new { @class = "text-danger" })

                    @if (withDomainMode)
                    {
                        <div class="row">
                            <div class="col-md-offset-9 col-md-3 right">
                                @if (CloudStorageLight.Core.SystemSettings.Instance.CanCreateCloudAccountOnline)
                                {
                                    @Html.ActionLink(CloudStorageLight.Core.Web.ViewMessages.MsgCreateCloudStorageLight, "CreateCloudAccount", query)
                                }
                            </div>
                        </div>
                        <div class="form-group">
                            <span class="col-md-3 control-label">@(CloudStorageLight.Core.Web.ViewMessages.MsgCloudAccount)</span>
                            <div class="col-md-5">
                                @Html.TextBox("cloudAccount", "", new { @class = "form-control" })
                                @Html.ValidationMessage("cloudAccount", "", new { @class = "text-danger" })
                            </div>
                            <div class="col-md-4">
                            </div>
                        </div>
                    }
                    <div class="form-group">
                        <span class="col-md-3 control-label">@(CloudStorageLight.Core.Web.ViewMessages.MsgEmail)</span>
                        <div class="col-md-5">
                            @Html.TextBox("email", "", new { @class = "form-control" })
                            @Html.ValidationMessage("email", "", new { @class = "text-danger" })
                        </div>
                    </div>
                    <div class="form-group">
                        <span class="col-md-3 control-label">@(CloudStorageLight.Core.Web.ViewMessages.MsgPassword)</span>
                        <div class="col-md-5">
                            @Html.Password("password", "", new { @class = "form-control" })
                            @Html.ValidationMessage("password", "", new { @class = "text-danger" })
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-md-offset-3 col-md-5">
                            <input type="submit" value="@(CloudStorageLight.Core.Web.ViewMessages.MsgLogin)" class="btn btn-default" />
                        </div>
                    </div>
                </form>
            </section>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(function () {
        if (typeof Storage !== "undefined") {
            var token = localStorage.getItem("clientToken");
            if (token != null) $("#ClientToken").val(token);
        }
    });
</script>
